package com.ruoyi.project.digital.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.digital.domain.Mood;
import com.ruoyi.project.digital.service.IMoodService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 心情列Controller
 * 
 * @author ruoyi
 * @date 2023-10-28
 */
@RestController
@RequestMapping("/digital/mood")
public class MoodController extends BaseController
{
    @Autowired
    private IMoodService moodService;

    /**
     * 查询心情列列表
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mood mood)
    {
        startPage();
        List<Mood> list = moodService.selectMoodList(mood);
        return getDataTable(list);
    }

    /**
     * 导出心情列列表
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:export')")
    @Log(title = "心情列", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Mood mood)
    {
        List<Mood> list = moodService.selectMoodList(mood);
        ExcelUtil<Mood> util = new ExcelUtil<Mood>(Mood.class);
        return util.exportExcel(list, "mood");
    }

    /**
     * 获取心情列详细信息
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(moodService.selectMoodById(id));
    }

    /**
     * 新增心情列
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:add')")
    @Log(title = "心情列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mood mood)
    {
        return toAjax(moodService.insertMood(mood));
    }

    /**
     * 修改心情列
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:edit')")
    @Log(title = "心情列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mood mood)
    {
        return toAjax(moodService.updateMood(mood));
    }

    /**
     * 删除心情列
     */
    @PreAuthorize("@ss.hasPermi('digital:mood:remove')")
    @Log(title = "心情列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(moodService.deleteMoodByIds(ids));
    }
}
